<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/4/15
 * Time: 9:42
 */

namespace Admin\Controller;


use Think\Controller;

class AdminAddController extends Controller
{
    /**
     * 管理员注册跳转
    **/
    public function adminSkip(){
        $this->display('index/adminAdd');
    }
    /**
     * 管理员注册信息
    **/
    public function adminAdd(){
//        $upload = new \Think\Upload();// 实例化上传类
//        $upload->maxSize=3145728 ;// 设置附件上传大小
//        $upload->exts=array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
//        $upload->rootPath = './';
//        $upload->savePath ='./Public/Admin/Uploads/'; // 设置附件上传目录
//        $upload->autoSub=false;
//        $upload->saveName = array('uniqid','');
//        $info   =   $upload->uploadOne($_FILES['a_pic']);
//        if(!$info) {// 上传错误提示错误信息
//            $this->error($upload->getError());
//        }else{// 上传成功
//            $pictrueName=$info['savename'];
//        }
        $a_name=I('a_name');
        $a_email=I('a_email');
        $a_pwd=I('a_pwd');
        $a_repwd=I('a_repwd');
        $a_tel=I('a_tel');
        $a_department=I('a_department');
        if(empty($a_name)||empty($a_email)||empty($a_pwd)||empty($a_repwd)||empty($a_tel)||empty($a_department)){
            $this->error('信息不能为空！');
        }
        if($a_pwd!=$a_repwd){
            $this->error('密码不同',null,true);
        }
        $email=D('AdminAdd')->getAdminEmail($a_email);
        if($email==true){
            $this->error('邮箱存在',null,true);
        }
        $res=D('AdminAdd')->UserRegister($a_name,$a_email,$a_pwd,$a_tel,$a_department);
        if($res>0){
            $this->success('添加成功',null,true);
        }else{
            $this->error('添加失败',null,true);
        }
    }
}